package cn.edu.guet.jdbc.day01;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class CRUD {
	
	public void create() throws SQLException{
		Connection conn = null;
		Statement st = null;
		ResultSet rs = null;
		
		try{
			conn = JdbcUtils.getInstance().getConnection();
			st = conn.createStatement();
			String sql = "";
			st.executeUpdate(sql);
		}finally{
			JdbcUtils.getInstance().free(rs, st, conn);
		}
		
	}

	public void read()throws SQLException{
		Connection conn = null;
		Statement st = null;
		ResultSet rs = null;
		
		try{
			conn = JdbcUtils.getInstance().getConnection();
			st = conn.createStatement();
			String sql = "";
			rs = st.executeQuery(sql);
		}finally{
			JdbcUtils.getInstance().free(rs, st, conn);
		}
	}
	
	public void read(String name)throws SQLException{
		Connection conn = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
		
		try{
			conn = JdbcUtils.getInstance().getConnection();
			
			String sql = "select name from user where name =?";
			ps = conn.prepareStatement(sql);	
			ps.setString(1, name);
			
			rs = ps.executeQuery();
		}finally{
			JdbcUtils.getInstance().free(rs, ps, conn);
		}
	}

	public void update()throws SQLException{
		Connection conn = null;
		Statement st = null;
		ResultSet rs = null;
		
		try{
			conn = JdbcUtils.getInstance().getConnection();
			st = conn.createStatement();
			String sql = "";
			st.executeUpdate(sql);
		}finally{
			JdbcUtils.getInstance().free(rs, st, conn);
		}
	}
	
	public void delete()throws SQLException{
		Connection conn = null;
		Statement st = null;
		ResultSet rs = null;
		
		try{
			conn = JdbcUtils.getInstance().getConnection();
			st = conn.createStatement();
			String sql = "";
			rs = st.executeQuery(sql);
		}finally{
			JdbcUtils.getInstance().free(rs, st, conn);
		}
	}
	
	public static void main(String[] arg){
		
	}
}
